//
//  UIButton+XMSDWebImage.m
//  Fireball
//
//  Created by 俞渊华 on 2017/12/4.
//  Copyright © 2017年 俞渊华. All rights reserved.
//

#import "UIButton+XMSDWebImage.h"

@implementation UIButton (XMSDWebImage)
- (void)xm_setImageWithURL:(NSString *)urlStr forState:(UIControlState)state{
    [self xm_setImageWithURL:urlStr forState:state placeholderImage:nil];
}

- (void)xm_setImageWithURL:(NSString *)urlStr forState:(UIControlState)state placeholderImage:(UIImage *)placeholder{
    [self xm_setImageWithURL:urlStr forState:state placeholderImage:placeholder completed:nil];
}

- (void)xm_setImageWithURL:(NSString *)urlStr forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDExternalCompletionBlock)completedBlock{
    NSURL * url = [NSURL URLWithString:[urlStr stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]];
    [self sd_setImageWithURL:url forState:state placeholderImage:placeholder completed:completedBlock];
}


- (void)xm_setBackgroundImageWithURL:(NSString *)urlStr forState:(UIControlState)state{
    [self xm_setBackgroundImageWithURL:urlStr forState:state placeholderImage:nil];
}

- (void)xm_setBackgroundImageWithURL:(NSString *)urlStr forState:(UIControlState)state placeholderImage:(UIImage *)placeholder{
    [self xm_setBackgroundImageWithURL:urlStr forState:state placeholderImage:placeholder completed:nil];
}

- (void)xm_setBackgroundImageWithURL:(NSString *)urlStr forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDExternalCompletionBlock)completedBlock{
    NSURL * url = [NSURL URLWithString:[urlStr stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]];
    [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder completed:completedBlock];
}
@end
